package com.richapp.launcher.net.box.tcp.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by jack on 15/11/24.
 */
public class BoxClientManager {

    private static Map<String,BoxClient> map = new HashMap<String, BoxClient>();

    public static void add(String boxCpuId,BoxClient boxClient){
        if(map.containsKey(boxCpuId)){
            del(boxCpuId);
        }
        map.put(boxCpuId,boxClient);
    }

    public static void del(String boxCpuId){
        if(map.containsKey(boxCpuId)){
            map.remove(boxCpuId);
        }
    }

    public static BoxClient get(String boxCpuId){
        if(map.containsKey(boxCpuId)){
            return  map.get(boxCpuId);
        }
        return null;
    }

    public static List<BoxClient> getAll(){
        List<BoxClient> boxClients = new ArrayList<BoxClient>();
        boxClients.addAll(map.values());
        return  boxClients;
    }
}
